package com.Dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.entity.Employee;

import util.DBHelp;
import util.RowMapper;
  public class EmployeeDao {
	
	private DBHelp<Employee> db =new DBHelp<Employee>();
	
	public Employee findByNameAndPassword(String username,String password){
		String sql="select id,username,password,supper from t_employee where username=? and password=?";
		return db.queryForObject(sql, new Mr(),username,password);
	}
	class Mr implements RowMapper<Employee>{
		public Employee mapperRow(ResultSet rs) throws SQLException {
			Employee em=new Employee();
			em.setId(rs.getInt("id"));
			em.setUsername(rs.getString("username"));
			em.setPassword(rs.getString("password"));
			em.setSupper(rs.getBoolean("supper"));
			return em;
		}
		
	}
	public void edit(Employee e) {
		String sql="UPDATE t_employee SET `supper`= ? WHERE id = ?";
		db.executeSQL(sql, e.isSupper(),e.getId());
		
	}
	

}
